import 'package:flutter/material.dart';
import 'data/storage_utils.dart'; // 导入 storage_utils.dart 文件
import 'package:audioplayers/audioplayers.dart';
import 'package:word_card/models/word_card.dart';
import 'data/sample_data.dart';
import 'pages/home_page.dart';
import 'pages/test_page.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized(); // 确保初始化完成

  // 测试保存和获取数据
  final testObject = {'name': 'John', 'age': 30};
  await StorageUtils.save("test", testObject);
  final retrievedObject = await StorageUtils.get<Map<String, dynamic>>("test", (json) => json);
  print('Retrieved Object: $retrievedObject');

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '旺卡单词',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
      routes: {
        '/test': (context) => const TestPage(),
      },
    );
  }
}
